//object js对象
let a4: object;

//{}用来指定对象中可以包含哪些属性
//{属性名：属性值,属性名?：属性值}
//属性名后加?表示可选属性
let b4: { name: string, age?: number };
b4 = { name: '机智勇敢' }


//[propName:string]:any 表示可以有任意类型的属性
let c4: { name: string, [propName: string]: any }


//设置函数结构的类型声明
//  (形参:类型,形参:类型)=>返回值类型
let d4: (a: number, b: number) => number
d4 = function (n1, n2): number {
  return n1 + n2
}

//数组 array
//  string[]表示字符串数组
let e4: string[]
let f4: number[]
let g4: Array<number>

//元组 tuple 固定长度的数组
let h4: [string, string]
h4 = ['hello', 'hello']

// enum 枚举
enum Gender {
  Male,
  Female
}
let i4: { name: string, gender: Gender }
i4 = {
  name: '机智勇敢',
  gender: 0
}

//&且
let j4: { name: string } & { age: number }
j4 = { name: '机智勇敢', age: 18 }

//类型的别名
type myType = 1 | 2 | 3 | 4 | 5
let m4: myType
m4 = 4